package modules.majiang.view
{
	import flash.display.MovieClip;
	
	import protobuf.BET_POOL;
	
	import utils.FloatHandler;

	/**
	 *
	 * @author xumin.xu 2013-1-28
	 */

	public class BonusPotViewProxy
	{
		private var bonusPot:MovieClip;

		private var betPosImgArray:Array;

		public function BonusPotViewProxy(bonusPot:MovieClip)
		{
			this.bonusPot = bonusPot;

			bonusPot.potpos1_mc.gotoAndStop(1);
			bonusPot.potpos2_mc.gotoAndStop(1);
			bonusPot.potpos3_mc.gotoAndStop(1);
			bonusPot.potpos4_mc.gotoAndStop(1);
			bonusPot.potpos5_mc.gotoAndStop(1);
			bonusPot.potpos6_mc.gotoAndStop(1);

			betPosImgArray = [bonusPot.potpos1_mc, bonusPot.potpos2_mc, bonusPot.potpos3_mc, bonusPot.potpos4_mc, bonusPot.potpos5_mc, bonusPot.potpos6_mc];

			bonusPot.visible = false;
		}

		/**
		 * 更新界面
		 **/
		public function updateView(betPool:BET_POOL):void
		{
			clearAllBet();

			var chairId:int;
			//显示奖池拥有者
			for each (chairId in betPool.chairList)
			{
				betPosImgArray[chairId - 1].gotoAndStop(2);;
			}
			//显示奖池金额
			bonusPot.potAmount_txt.text = FloatHandler.TwoFormatToString(betPool.money);
		}

		private function clearAllBet():void
		{
			var length:int = betPosImgArray.length;
			for (var i:int = 0; i < length; i++)
			{
				betPosImgArray[i].gotoAndStop(1);
			}
		}

		public function setVisible(visible:Boolean):void
		{
			bonusPot.visible = visible;
		}
	}
}
